<?php
include_once 'fun.php';
include_once 'islogin.php';
    //var_dump($_FILES);
    $Name = trim($_POST['Name']);
    $id=(int)$_POST['id'];
    //var_dump($id);
   // $pic='pics/default.PNG';
    if(empty($Name))
    {
        alertMes("姓名不能为空",'stuff.php');
        exit;
    }
   
    else
    {
        $con=connect();
        $sql = "select managerid from manager where Name like '$Name' ";
        $res=query($sql,$con);
        $a=mysqli_fetch_row($res);
        if($res->num_rows>1||($res->num_rows==1&&$a[0]!=$id)){
            alertMes("姓名不能相同",'stuff.php');
            exit;
        }
        $sql = "update manager set Name='{$Name}' where managerid={$id}";
        query($sql,$con);
        echo '保存成功';
        
    header('Refresh:0;url=stuff.php');
    
    }
    
    
?>